package geppetto.main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

public class ReverseTable {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		String input = args[0];
		String output = args[1];
		String encoding = args[2];
		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(input), encoding));
		PrintStream writer = new PrintStream(new File(output), encoding);
		while(reader.ready()){
			String line = reader.readLine();
			String[] extract = line.split(" \\|\\|\\| ");
			String entry = extract[1] + " ||| " + extract[0] + " ||| " + extract[2];
			if(extract.length > 2){
				for(int i = 3; i<extract.length; i++){
					entry += " ||| " + extract[i];
				}
			}
			writer.println(entry);
		}
	}

}
